package org.git.movie.controller;

import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.git.movie.annotations.Verify;
import org.git.movie.form.VodRecommendForm;
import org.git.movie.service.IVodRecommendService;
import org.git.movie.util.BaseController;
import org.git.movie.util.BaseResponse;
import org.git.movie.vo.PageDto;
import org.git.movie.vo.VodRecommendDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author sqyc
 */
@Controller
@RequestMapping("vodrecommend")
@Slf4j
public class VodRecommendController extends BaseController {

    @Autowired
    private IVodRecommendService vodRecommendService;


//    @SentinelResource(value = "VodRecommendServiceImplFindPage" ,entryType = EntryType.IN)
    @ResponseBody
    @RequestMapping(value = "/findpage.do", method = {RequestMethod.POST,RequestMethod.GET})
    public BaseResponse<PageDto<VodRecommendDto>> vodrecommend_findpage(
            VodRecommendForm vodRecommendForm ,
            @Verify(param="pageNo",rule="required|min(1)") int pageNo,
            @Verify(param="pageSize",rule="required|min(3)|max(60)") int pageSize) {

        PageDto<VodRecommendDto> page = vodRecommendService.findPage(vodRecommendForm,pageNo,pageSize);
        return   ok(page);
    }

    @ResponseBody
    @RequestMapping(value = "/findbyid.do", method = {RequestMethod.POST,RequestMethod.GET})
    public BaseResponse<VodRecommendDto> findbyid(

            @Verify(param="id",rule="required|min(1)") Integer id) {

        VodRecommendDto record = vodRecommendService.findById(id);
        return   ok(record);
    }

}
